﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Collections.ObjectModel;
using GeoFinderClientApp.Model;
using GeoFinderClientApp.ViewModel;

namespace GeoFinderClientApp.View
{
    public partial class FirstLogin : PhoneApplicationPage
    {
        public ViewModels vm;
        public FirstLogin()
        {
            InitializeComponent();
            vm = new ViewModels();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            vm.GetPushOptions();

            PushSettingsControl.DataContext = (from elem in vm.PushOptions select elem.GetCopy()).ToList<PushOption>();
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            var mod = new ObservableCollection<PushOption>();
            foreach (var item in PushSettingsControl.DataContext as List<PushOption>)
            {
                mod.Add(item);
            }
            vm.PushOptions = mod;
            vm.SavePushOptions();
            MessageBox.Show("Finished saving Push Options");
            NavigationService.Navigate(new Uri("/View/FacebookLogin.xaml", UriKind.Relative));
        }
    }
}